import React from "react";
import {Navigate} from "react-router-dom";
import Home from "../pages/Home";
import HomeRecommend from "../pages/HomeRecommend";
import HomeRanking from "../pages/HomeRanking";
import HomeSongs from "../pages/HomeSongs";
// import About from "../pages/About";
// import Login from "../pages/Login";
import Category from "../pages/Category";
import Order from "../pages/Order";
import Detail from "../pages/Detail";
import User from "../pages/User";
import NotFound from "../pages/NotFound";

//路由懒加载, 会进行单独打包, 在客户端需要对这个页面单独进行下载
const About = React.lazy(() => import('../pages/About'))
const Login = React.lazy(() => import('../pages/Login'))

//路由配置
const routes = [
  {
    path: '/',
    element: <Navigate to='/home'/>
  },
  {
    path: '/home',
    element: <Home/>,
    children: [
      {
        path: '/home',
        element: <Navigate to='/home/recommend'/>
      },
      {
        path: '/home/recommend',
        element: <HomeRecommend/>
      },
      {
        path: '/home/ranking',
        element: <HomeRanking/>
      },
      {
        path: '/home/songs',
        element: <HomeSongs/>
      },
    ]
  },
  {
    path: '/about',
    element: <About/>
  },
  {
    path: 'login',
    element: <Login/>
  },
  {
    path: 'category',
    element: <Category/>
  },
  {
    path: 'order',
    element: <Order/>
  },
  {
    path: '/detail/:id',
    element: <Detail/>
  },
  {
    path: '/user',
    element: <User/>
  },
  {
    path: '*',
    element: <NotFound/>
  }
]

export default routes;